package com.googlecode.imanager.jasper.util;

import com.googlecode.imanager.jasper.print.RChild;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class RHorizontalPrintComparator extends RPrintComparator {

    public static final RHorizontalPrintComparator INSTANCE = new RHorizontalPrintComparator();
    
    protected RHorizontalPrintComparator() {
    }
    
    @Override
    public int getLength(RChild a) {
        return a.getWidth() + ((RChild)a).getRInsets().getHorizontal();
    }

    @Override
    public int getStartPos(RChild a) {
        return a.getX() - ((RChild)a).getRInsets().getLeft();
    }

    @Override
    public void setLength(RChild a, int value) {
        a.setWidth(value - ((RChild)a).getRInsets().getHorizontal());
    }

    @Override
    public void setStartPos(RChild a, int value) {
        a.setX(value + ((RChild)a).getRInsets().getLeft());
    }
    
    @Override
    public RPrintComparator getOpposition() {
        return RVerticalPrintComparator.INSTANCE;
    }
    
}